package demo.config;

import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;
import demo.controller.HelloController;
import demo.interceptor.GlobalInterceptor;
import demo.model.User;

/**
 *jfinal配置类
 * Created by ldt on 2017/5/23.
 */
public class DemoConfig extends JFinalConfig{
    //配置jfinal常量值
    public void configConstant(Constants constants) {
        constants.setDevMode(true);
    }
    //控制路由
    public void configRoute(Routes routes) {
        routes.add("hello", HelloController.class);
    }
    //模板引擎
    public void configEngine(Engine engine) {

    }
    //插件
    public void configPlugin(Plugins plugins) {
        DruidPlugin dp = new DruidPlugin("jdbc:mysql://172.41.8.106:3306/activiti",
                "root","123456","com.mysql.jdbc.Driver");
        plugins.add(dp);
        ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
        plugins.add(arp);
        arp.addMapping("user",User.class);
        arp.setDevMode(true);
    }
    //拦截器
    public void configInterceptor(Interceptors interceptors) {
        interceptors.addGlobalActionInterceptor(new GlobalInterceptor());

    }

    public void configHandler(Handlers handlers) {

    }
}
